package study;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * @version 1.0
 * @since:
 * @ClassName:HashSetTest
 * @author: Li Jiahui
 * @date: 2021-05-02 0:00
 */
public class HashSetTest {
    public static void main(String[] args) {
        //1.声明一个Set类型的引用指向HashSet类型的对象
        Set<String> s1 = new LinkedHashSet<>();
        System.out.println("s1 = " + s1);//这里啥也没有
        System.out.println("-----------------------");
        boolean b1 = s1.add("two");
        System.out.println("b1 =" + b1);
        System.out.println("s1 = " + s1);

        b1 = s1.add("one");
        System.out.println("b1 =" + b1);
        System.out.println("s1 = " + s1);

        b1 = s1.add("three");
        System.out.println("b1 =" + b1);
        System.out.println("s1 = " + s1);

        b1 = s1.add("one");
        System.out.println("b1 =" + b1);
        System.out.println("s1 = " + s1);

        //2.声明一个Set类型的引用指向HashSet类型的对象
        Set<String> s2 = new LinkedHashSet<>();
        System.out.println("s1 = " + s1);//这里啥也没有
        System.out.println("-----------------------");
        boolean b2 = s1.add("two");
        System.out.println("b2 =" + b1);
        System.out.println("s2 = " + s1);

        b2 = s2.add("one");
        System.out.println("b2 =" + b1);
        System.out.println("s2 = " + s1);

        b2 = s2.add("three");
        System.out.println("b2 =" + b1);
        System.out.println("s2 = " + s1);

        b2 = s2.add("one");
        System.out.println("b2 =" + b1);
        System.out.println("s2 = " + s1);


    }


}
